package com.xxwy.usercenter.controller;

import com.xxwy.usercenter.dao.user.UserMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wy
 * @date 2020/3/4 0:58
 */
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class UserController {

  private DiscoveryClient discoveryClient;
  private UserMapper userMapper;

  @GetMapping("user/hi")
  public String test(){
    return "user hi";
  }

  @GetMapping("user/hi2")
  public List<ServiceInstance> test2() {
    List<ServiceInstance> instances = discoveryClient.getInstances("share-center");
    return instances;
  }

}
